package com.whf.Controller;

import com.whf.service.SecKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 秒杀controller
 */
@Slf4j
@RestController
public class SecKillController {

    @Autowired
    private SecKillService secKillService;
    //查询秒杀特价商品的信息
    @GetMapping("/query/{productId}")
    public String query(@PathVariable String productId){
        return secKillService.querySecKillProductInfo(productId);
    }
    //秒杀,没抢到提示:"哎呦喂,赶紧再试试哦",抢到返回剩余的库存量
    @GetMapping("/order/{productId}")
    public String skill(@PathVariable String productId){
       secKillService.orderProductMockDiffUser(productId);
       return secKillService.querySecKillProductInfo(productId);
    }
}
